package com.zjj.concurrent.completableFuture;

import java.util.concurrent.CompletableFuture;

/**
 * @author zhanglei.zjj
 * @description 使用ThenApply做结果转换，将上一阶段的结果进行第二阶段转换，操作的是同一个CompletableFuture
 * @date 2023/6/3 18:00
 */
public class ThenApplyTest {
    public static void main(String[] args) {
        CompletableFuture<String> future = CompletableFuture.supplyAsync(() -> {
            int result = 100;
            System.out.println("一阶段：" + result);
            return result;
        }).thenApply(number -> {
            int result = number * 3;
            System.out.println("二阶段：" + result);
            return result + "";
        });

        System.out.println("最终结果：" + future.join());
    }
}
